package service;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccc.dao.LoanDao;
import com.ccc.model.Loan;
import com.ccc.service.LoanService;
import com.ccc.service.UserService;

public class LoanServiceTest {
	
	private static LoanService loanService;
	private static UserService userService;
	private static LoanDao loanDao;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ApplicationContext ac = new  ClassPathXmlApplicationContext("beans.xml");
		loanService = (LoanService)ac.getBean("loanService");
		userService = (UserService)ac.getBean("userService");
		loanDao = (LoanDao)ac.getBean("loanDao");
	}

	@Test
	public void testAddLoan() {
//		Loan loan = new Loan();
//		loan.setCurrentTime(1);
//		loan.setLoan(100);
//		loan.setLoanTime(1);
//		loan.setUser(userService.findUser(1));
		Loan loan = loanDao.findLoan(2);
//		loan.setLoanId(null);
		loanDao.addLoan(loan);
	}

}
